package com.kittlen.springBootDemo.mapper;

import com.kittlen.springBootDemo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author kittlen
 * @version 1.0
 * @date 2020/12/7 16:49
 */

/**
 DROP TABLE IF EXISTS `t_user`;
 CREATE TABLE `t_user`  (
 `id` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
 `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
 `password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
 PRIMARY KEY (`id`) USING BTREE
 ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

 -- ----------------------------
 -- Records of t_user
 -- ----------------------------
 INSERT INTO `t_user` VALUES ('1', '张三', '123456');
 INSERT INTO `t_user` VALUES ('2', '李四', '123456');

 SET FOREIGN_KEY_CHECKS = 1;
/**
 * 接口要添加 @Mapper 注解，这样容器中才会有接口的实现类
 */
@Mapper
public interface UserMappers {

    @Select("select * from t_user")
    List<User> selectUser();

    @Select("select * from t_user where id = #{id}")
    User selectById(String id);
}
